package com.nuanshui.framework.utils;

/*
 * 与操作，直接位结果值操作比较
 */
public class ResultFlagOperation implements IFlagOperation {

	public long addFlag(long currentFlag, int dwFlag) {
		currentFlag |= dwFlag;

		return currentFlag;
	}

	public long removeFlag(long currentFlag, int dwFlag) {
		long flag = currentFlag & ~dwFlag;
		return flag;
	}

	public boolean containFlag(Long currentFlag, int dwFlag) {
		if(currentFlag==null) return false;
		return internalContainFlag(currentFlag,dwFlag);
	}

	public boolean containFlag(long currentFlag, int dwFlag) {
		return internalContainFlag(currentFlag,dwFlag);
	}

	private boolean internalContainFlag(long currentFlag, int dwFlag) {
		boolean bFlag = false;
		long nVal = currentFlag & dwFlag;
		if (nVal > 0)
			bFlag = true;
		return bFlag;

	}

	public static void main(String[] args) throws Exception {


		int GUIELEMENT_STATUS_FLOAT = 0x1 << 3;
		int GUIELEMENT_STATUS_DESTROY = 0x1 << 4;

		int test = GUIELEMENT_STATUS_DESTROY | GUIELEMENT_STATUS_FLOAT;
		IFlagOperation flagOperation=FlagOperationFactory.getResultOp();
		System.out.println(flagOperation.containFlag(test, GUIELEMENT_STATUS_DESTROY));

	}
}
